package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import java.util.Date;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.*;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Null;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * @author shihu
 * @mail m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(name = "产品表Po")
public class ProductPo extends BasePo{
  @NotNull(groups = {IUpdateVo.class}, message = "id不能为空")
  @Schema(name = "主键ID")
  private Long id;

  @NotNull(groups = {IInsertVo.class},message = "产品名称不能为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 32, message = "name长度范围最大32")
  @Schema(name = "产品名称")
  private String name;

  @NotNull(groups = {IInsertVo.class},message = "产品编码不能为空")
  @Null(groups = {IUpdateVo.class},message = "产品编码必须为空")
  @Size(groups = {IUpdateVo.class,IInsertVo.class},max = 32, message = "code长度范围最大32")
  @Schema(name = "产品编码")
  private String code;

  @Schema(name = "租户")
  private Long tenantId;

  @Schema(name = "排序值")
  private Integer sort;

  @NotNull(groups = {IUpdateVo.class}, message = "更新版本不能为空")
  @Schema(name = "更新版本")
  private Integer updateVersion;

  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(name = "创建时间")
  private Date createTime;

  @JsonFormat(timezone = "GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
  @Schema(name = "更新时间")
  private Date updateTime;



  public void initLoginAccount(ILoginAccount loginAccount){
    this.tenantId = loginAccount.getTenantId();
  }
}



